package com.amazon.ags.client.achievements;

import android.util.Log;
import com.amazon.ags.api.AGResponseHandle;
import com.amazon.ags.api.AmazonGamesStatus;
import com.amazon.ags.api.ErrorCode;
import com.amazon.ags.api.RequestResponse;
import com.amazon.ags.api.achievements.AchievementsClient;
import com.amazon.ags.api.achievements.GetAchievementResponse;
import com.amazon.ags.api.achievements.GetAchievementsResponse;
import com.amazon.ags.api.achievements.LoadIconResponse;
import com.amazon.ags.api.achievements.UpdateProgressResponse;
import com.amazon.ags.client.AmazonGamesService;
import com.amazon.ags.client.GCResponseHandleImpl;
import com.amazon.ags.client.RequestResponseImp;
import com.amazon.ags.constants.IconSize;

public class AchievementsClientImpl
  implements AchievementsClient
{
  private static final String FEATURE_NAME = "AC";
  private static final String TAG = "AC_" + AchievementsClientImpl.class.getSimpleName();
  private final AchievementsService achievementsService;
  private final AmazonGamesService amazonGamesService;

  public AchievementsClientImpl(AmazonGamesService paramAmazonGamesService, AchievementsService paramAchievementsService)
  {
    this.amazonGamesService = paramAmazonGamesService;
    this.achievementsService = paramAchievementsService;
  }

  private boolean canUpdateAchievement()
  {
    AmazonGamesStatus localAmazonGamesStatus = this.amazonGamesService.getStatus();
    switch (1.$SwitchMap$com$amazon$ags$api$AmazonGamesStatus[localAmazonGamesStatus.ordinal()])
    {
    default:
      return true;
    case 1:
    case 2:
    case 3:
    case 4:
    }
    return false;
  }

  public final AGResponseHandle<GetAchievementResponse> getAchievement(String paramString, Object[] paramArrayOfObject)
  {
    GCResponseHandleImpl localGCResponseHandleImpl = new GCResponseHandleImpl(paramArrayOfObject);
    if (!this.amazonGamesService.isReady())
    {
      Log.d(TAG, "Service not ready");
      localGCResponseHandleImpl.setResponse(new GetAchievementResponseImp(20, ErrorCode.SERVICE_NOT_READY));
      return localGCResponseHandleImpl;
    }
    this.achievementsService.requestAchievement(paramString, localGCResponseHandleImpl);
    return localGCResponseHandleImpl;
  }

  public final AGResponseHandle<GetAchievementsResponse> getAchievements(Object[] paramArrayOfObject)
  {
    GCResponseHandleImpl localGCResponseHandleImpl = new GCResponseHandleImpl(paramArrayOfObject);
    if (!this.amazonGamesService.isReady())
    {
      Log.d(TAG, "Service not ready");
      localGCResponseHandleImpl.setResponse(new GetAchievementsResponseImp(20, ErrorCode.SERVICE_NOT_READY));
      return localGCResponseHandleImpl;
    }
    this.achievementsService.requestAchievements(localGCResponseHandleImpl);
    return localGCResponseHandleImpl;
  }

  public AGResponseHandle<LoadIconResponse> loadIcon(String paramString, IconSize paramIconSize, boolean paramBoolean, Object[] paramArrayOfObject)
  {
    GCResponseHandleImpl localGCResponseHandleImpl = new GCResponseHandleImpl(paramArrayOfObject);
    if (!this.amazonGamesService.isReady())
    {
      Log.d(TAG, "Service not ready");
      localGCResponseHandleImpl.setResponse(new LoadIconResponseImp(20, ErrorCode.SERVICE_NOT_READY));
      return localGCResponseHandleImpl;
    }
    this.achievementsService.loadIcon(paramString, paramIconSize, paramBoolean, localGCResponseHandleImpl);
    return localGCResponseHandleImpl;
  }

  public final AGResponseHandle<RequestResponse> resetAchievement(String paramString, Object[] paramArrayOfObject)
  {
    GCResponseHandleImpl localGCResponseHandleImpl = new GCResponseHandleImpl(paramArrayOfObject);
    if (!this.amazonGamesService.isReady())
    {
      Log.d(TAG, "Service not ready");
      localGCResponseHandleImpl.setResponse(new RequestResponseImp(20, ErrorCode.SERVICE_NOT_READY));
      return localGCResponseHandleImpl;
    }
    this.achievementsService.resetAchievement(paramString, localGCResponseHandleImpl);
    return localGCResponseHandleImpl;
  }

  public final AGResponseHandle<RequestResponse> resetAchievements(Object[] paramArrayOfObject)
  {
    GCResponseHandleImpl localGCResponseHandleImpl = new GCResponseHandleImpl(paramArrayOfObject);
    if (!this.amazonGamesService.isReady())
    {
      Log.d(TAG, "Service not ready");
      localGCResponseHandleImpl.setResponse(new RequestResponseImp(20, ErrorCode.SERVICE_NOT_READY));
      return localGCResponseHandleImpl;
    }
    this.achievementsService.resetAchievements(localGCResponseHandleImpl);
    return localGCResponseHandleImpl;
  }

  public final AGResponseHandle<RequestResponse> showAchievementsOverlay(Object[] paramArrayOfObject)
  {
    GCResponseHandleImpl localGCResponseHandleImpl = new GCResponseHandleImpl(paramArrayOfObject);
    if ((this.amazonGamesService.isReady()) || (this.amazonGamesService.getStatus() == AmazonGamesStatus.SERVICE_NOT_OPTED_IN))
    {
      this.achievementsService.showAchievementsOverlay(localGCResponseHandleImpl);
      return localGCResponseHandleImpl;
    }
    Log.d(TAG, "Service not ready");
    localGCResponseHandleImpl.setResponse(new RequestResponseImp(20, ErrorCode.SERVICE_NOT_READY));
    return localGCResponseHandleImpl;
  }

  public final AGResponseHandle<UpdateProgressResponse> updateProgress(String paramString, float paramFloat, Object[] paramArrayOfObject)
  {
    GCResponseHandleImpl localGCResponseHandleImpl = new GCResponseHandleImpl(paramArrayOfObject);
    if ((!canUpdateAchievement()) && (this.amazonGamesService.getStatus() != AmazonGamesStatus.SERVICE_NOT_OPTED_IN))
    {
      Log.d(TAG, "Service not ready");
      localGCResponseHandleImpl.setResponse(new UpdateProgressResponseImp(20, ErrorCode.SERVICE_NOT_READY));
      return localGCResponseHandleImpl;
    }
    this.achievementsService.updateProgress(paramString, paramFloat, localGCResponseHandleImpl);
    return localGCResponseHandleImpl;
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.amazon.ags.client.achievements.AchievementsClientImpl
 * JD-Core Version:    0.6.2
 */